import myAxios from './myAxios.js'

//登录请求
export const reqLogin = loginForm => myAxios.post('login', loginForm)
// 获取所有菜单请求
export const reqMenus = () => myAxios.get('menus')
// 获取用户列表
export const reqUsers = queryInfo => myAxios.get('users', {
  params: queryInfo
})
// 修改用户状态的请求
export const reqUserState = (user) => myAxios.get(`users/${user.id}/state/${user.mg_state}`)

// 添加新用户的请求
export const reqAddUsers = (user) => myAxios.post('users', user)

// 查询编辑用户信息
export const reqQueryUserInfo = (id) => myAxios.get('users/' + id)

// 编辑用户信息
export const reqEditUserInfo = ({
  email,
  mobile,
  id,
}) => myAxios.put('users/' + id, {
  params: {
    email,
    mobile,
  }
})


// 删除用户用户信息
export const reqDeleteUserInfo = (id) => myAxios.delete('users/' + id)

// 获取权限列表
export const reqRightsList = () => myAxios.get('rights/list')

// 获取角色列表
export const reqRoles = () => myAxios.get('roles')

// 获取添加角色
export const reqAddRoles = ({
  roleName,
  roleDesc
}) => myAxios.post('roles', {
  roleName,
  roleDesc
})

//删除角色指定权限
export const reqRemoveRolesRights = ({
  roleId,
  rightId
}) => myAxios.delete(`roles/${roleId}/rights/${rightId}`)

//获取所有权限列表
export const reqAllRights = () => myAxios.get('rights/tree')



//获取角色授权
export const reqAllotRights = (roleId, rids) => myAxios.post(`roles/${roleId}/rights`, {
  rids
})

// 分配用户角色

export const reqUserRole = (userId, rid) => myAxios.put(`users/${userId}/role`, {
  rid
})

// 获取商品分类数据列表
export const reqGoodsCategory = (queryInfo) => myAxios.get('categories', {
  params: queryInfo
})

// 获取一级二级商品分类数据列表
export const reqGoodsCategoryTow = () => myAxios.get('categories', {
  params: {
    type: 2
  }
})


// 获取添加分类
export const reqAddCategory = (cate) => myAxios.post('categories', cate)

// 获取商品分类数据列表
export const reqCateList = () => myAxios.get('categories')

//根据id获取 参数列表
export const reqCateById = ({
  id,
  sel
}) => myAxios.get(`categories/${id}/attributes`, {
  params: {
    sel
  }
})

// 添加动态参数或者静态属性
export const reqAddParams = ({
  cateId,
  attr_name,
  attr_sel

}) => myAxios.post(`categories/${cateId}/attributes`, {
  attr_name,
  attr_sel
})

// 根据 ID 查询参数

export const reqQueryParamsById = ({
  cateId,
  attrId,
  attr_sel
}) => myAxios.get(`categories/${cateId}/attributes/${attrId}`, {
  params: {
    attr_sel
  }
})

//  获取编辑提交参数
export const reqEditParamsById = ({
  cateId,
  attrId,
  attr_sel,
  attr_name,
  attr_vals
}) => myAxios.put(`categories/${cateId}/attributes/${attrId}`, {

  attr_sel,
  attr_name,
  attr_vals

})

// 删除商品参数
export const reqDeleteParams = ({
  cateId,
  attrId,

}) => myAxios.delete(`categories/${cateId}/attributes/${attrId}`)


// 获取商品列表
export const reqGoodsList = (queryinfo) => myAxios.get('goods', {
  params: queryinfo
})
// 删除商品
export const reqDeleteGoodsById = (id) => myAxios.delete(`goods/${id}`)

// 添加商品列表
export const reqAddGoodsList = (goodinfo) => myAxios.post('goods', goodinfo)

// 请求获取订单列表
export const reqOrderList = (ordersinfo) => myAxios.get('orders', {
  params: ordersinfo
})
//  查看物流信息
export const reqKuaiDiInfo = () => myAxios.get('kuaidi/1106975712662')

// 获取基于时间统计的折线图数据
export const reqreportsInfo = () => myAxios.get('reports/type/1')